#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn=1e6+7;
int n,k;
int d[Maxn];
int ans,dep[Maxn];
vector<int>e[Maxn];

void dfs(int u,int ft){
    dep[u]=dep[ft]+1;
    for(auto v:e[u]){
        if(v==ft) continue;
        if(!dep[v]) dfs(v,u);
    }
}

int main(){
    freopen("lost.in","r",stdin);
    freopen("lost.out","w",stdout);
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&d[i]);
    if(d[1]!=1) ans++,d[1]=1;
    for(int i=2;i<=n;i++) e[d[i]].emplace_back(i);
    dep[0]=-1;
    dfs(1,0);
    for(int i=2;i<=n;i++) if(dep[i]>k) ans++;
    printf("%d",ans);

    // system("pause");
    return 0;
}
/*
 4 1
 2 1 4 1
*/